package export.monster
{
	import base.BaseMonster;
	
	import com.game.manager.AnimationManager;
	
	import export.bullet.RegionBullet;
	
	import flash.geom.Rectangle;
	//虾兵
	public class Monster301 extends BaseMonster
	{
		public function Monster301()
		{
			super();
		}
		
		override protected function initBBDC():void
		{
			bbdc = AnimationManager.getAnimation("Monster301Action");
			bbdc.setAction("idle");
			bbdc.turnRight();
			bbdc.addCallBack(onEnterFrame, onActionOver);
			bodyContainer.addChild(bbdc);
		}
		
		override protected function initCollideArea():void
		{
			collideBox = new Rectangle(-25,-110,60,110);
			super.initCollideArea();
		}
		
		override protected function initAttribute():void
		{
			super.initAttribute();
			mavo.attackRange = 150;
		}
		
		override protected function onEnterFrame(action:String, frameCount:int):void
		{
			switch (action)
			{
				case "attack1":
					if(frameCount == 1)
					{
						var b:RegionBullet = new RegionBullet();
						b.setOwner(this);
						b.setHurt(getActionHurt("attack1"));
						b.setDirect(bbdc.getDirect());
						b.setCollideArea(0,-110,60 * bbdc.getDirect(),110);
						b.setAction("Monster301Attack1");
						b.setDestroyInCount(bbdc.frameLeft);
						gc.gameScene.addChild(b);
						magicBulletArray.push(b);
					}
					break;
			}
		}
	}
}


/*package export.monster
{
	import base.BaseBitmapDataClip;
	import base.BaseBitmapDataPool;
	import base.BaseMonster;
	
	import com.dusk.util.McUtil;
	import com.dusk.util.RandomUtil;
	import com.dusk.util.ResUtil;
	
	import export.bullet.EnemyMoveBullet;
	import export.bullet.FollowTargetBullet;
	
	import flash.display.Sprite;
	import flash.geom.Point;
	
	public class Monster301 extends BaseMonster
	{
		private var _m:String = "虾兵";
		
		public function Monster301()
		{
			super();
			this.horizonSpeed = 6;
			this.attackBackInfoDict["hit1"] = {
				"hitMaxCount"    : 99,
				"attackBackSpeed": [6, -5],
				"attackInterval" : 999,
				"power"          : 150,
				"attackKind"     : "magic"
			};
			this.attackBackInfoDict["hit2"] = {
				"hitMaxCount"    : 99,
				"attackBackSpeed": [6, -5],
				"attackInterval" : 999,
				"power"          : 150,
				"attackKind"     : "magic"
			};
			this.gravity = 0.2;
			this.setAction("idle");
		}
		
		private var isReadyToSwim:Boolean = false;
		
		override protected function initBBDC():void
		{
			var _loc1_:* = null;
			var _loc2_:Array = BaseBitmapDataPool.getBitmapDataArrayByName("Monster301");
			if (_loc2_)
			{
				_loc1_ = {
					"name"  : "body",
					"source": _loc2_
				};
				bbdc = new BaseBitmapDataClip([_loc1_], 200, 200, new Point(0, 0));
				bbdc.setOffsetXY(2, -12);
				bbdc.setFrameStopCount([[2, 2, 2, 3, 2, 4], [4, 4, 4, 4], [8, 20], [15], [2, 2, 2, 2, 10], [2, 10], [2, 2, 2, 10]]);
				bbdc.setFrameCount([6, 4, 2, 1, 5, 2, 4]);
				bbdc.setEnterFrameCallBack(this.enterFrameFunc, this.exitFrameFunc);
				bbdc.setAddScriptWhenFrameOver(this.scriptFrameOverFunc);
				this.bodyContainer.addChild(bbdc);
				return;
			}
			throw new Error("Monster301--BitmapData Error!");
		}
		
		override protected function initCollideArea():void
		{
			this.colipse = ResUtil.getNewObj("ObjectBaseSprite") as Sprite;
			this.colipse.visible = false;
			this.addChild(this.colipse);
		}
		
		override public function setAction(param1:String):void
		{
			if (!(!this.isReadyToSwim && this.standInObj))
			{
				if (this.curAction == "swim")
				{
					if (param1 != "dead" && param1 != "hit1" && param1 != "hurt")
					{
						if (!this.standInObj)
						{
							this.isReadyToSwim = false;
						}
						return;
					}
				}
			}
			super.setAction(param1);
			var _loc2_:Point = this.bbdc.getCurPoint();
			switch (param1)
			{
				case "idle":
					if (_loc2_.y != 0)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(0);
					}
					this.bbdc.setState(param1);
					break;
				case "walk":
					if (_loc2_.y != 1)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(1);
					}
					this.bbdc.setState(param1);
					break;
				case "swim":
					if (_loc2_.y != 2)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(2);
					}
					this.bbdc.setState(param1);
					break;
				case "hit1":
					if (_loc2_.y != 6)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(6);
					}
					this.bbdc.setState(param1);
					break;
				case "hit2":
					if (_loc2_.y != 5)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(5);
					}
					this.bbdc.setState(param1);
					break;
				case "hurt":
					if (_loc2_.y != 3)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(3);
					}
					this.bbdc.setState(param1);
					break;
				case "dead":
					if (_loc2_.y != 4)
					{
						this.bbdc.setFramePointX(0);
						this.bbdc.setFramePointY(4);
					}
					this.bbdc.setState(param1);
			}
		}
		
		override protected function scriptFrameOverFunc(param1:int):void
		{
			var _loc2_:String = this.bbdc.getState();
			switch (_loc2_)
			{
				case "walk":
					this.bbdc.setFramePointX(0);
					break;
				case "idle":
					this.bbdc.setFramePointX(0);
					break;
				case "hit1":
					if (!this.standInObj)
					{
						this.setAction("swim");
						break;
					}
					this.setAction("idle");
					break;
				case "hit2":
					if (!this.standInObj)
					{
						this.setAction("swim");
						break;
					}
					this.setAction("idle");
					break;
				case "hurt":
					if (!this.standInObj)
					{
						this.setAction("swim");
						break;
					}
					this.setAction("idle");
					break;
				case "swim":
					this.bbdc.setFramePointX(0);
					break;
				case "dead":
					this.dropAura();
					this.destroy();
			}
		}
		
		override protected function enterFrameFunc(param1:Point):void
		{
			var _loc2_:String = this.bbdc.getState();
			var _loc3_:uint = this.getBBDC().getDirect();
			switch (_loc2_)
			{
				case "hit1":
					if (param1.x == 2)
					{
						if (this.bbdc.getCurFrameCount() == 2)
						{
							this.doHi1(_loc3_);
							break;
						}
						break;
					}
					break;
				case "hit2":
					if (param1.x == 1)
					{
						if (this.bbdc.getCurFrameCount() == 10)
						{
							this.doHi2(_loc3_);
							break;
						}
						break;
					}
					break;
				case "swim":
					if (param1.x == 0)
					{
						if (this.bbdc.getCurFrameCount() == 8)
						{
							if (this.curAttackTarget)
							{
								if (this.y > this.curAttackTarget.y)
								{
									this.velocity.y = -6;
									break;
								}
								this.velocity.y = 5;
								break;
							}
							break;
						}
						break;
					}
					if (param1.x == 1)
					{
						if (this.curAttackTarget)
						{
							if (this.y > this.curAttackTarget.y)
							{
								this.velocity.y = -6 * Number(this.bbdc.getCurFrameCount()) / 20;
								break;
							}
							break;
						}
						break;
					}
					break;
			}
		}
		
		override protected function hasAttackTarget():void
		{
			var _loc1_:Number = Number(NaN);
			if (this.isBeAttacking() || this.isAttacking())
			{
				return;
			}
			if (!this.isAttacking() && !this.isBeAttacking())
			{
				if (Boolean(this.beforeSkill1Start()) && this.mavo.skillCD1[0] == 0)
				{
					this.releSkill1();
					this.mavo.skillCD1[0] = this.mavo.skillCD1[1];
				}
				else if (Boolean(this.beforeSkill2Start()) && this.mavo.skillCD2[0] == 0)
				{
					this.releSkill2();
					this.mavo.skillCD2[0] = this.mavo.skillCD2[1];
				}
				else if (Boolean(this.beforeSkill3Start()) && this.mavo.skillCD3[0] == 0)
				{
					this.releSkill3();
					this.mavo.skillCD3[0] = this.mavo.skillCD3[1];
				}
				else if (Boolean(this.beforeSkill4Start()) && this.mavo.skillCD4[0] == 0)
				{
					this.releSkill4();
					this.mavo.skillCD4[0] = this.mavo.skillCD4[1];
				}
				else if (_framer % gc.frameClips == 0)
				{
					_loc1_ = AUtils.GetDisBetweenTwoObj(this, this.curAttackTarget);
					if (_loc1_ <= this.mavo.attackRange)
					{
						if (RandomUtil.randBoolean(mavo.normalAttackRate))
						{
							this.attackTarget();
						}
						else if (_loc1_ <= 500)
						{
							this.keepDisWithTarget();
						}
						else
						{
							this.setAction("idle");
							this.setStatic();
						}
					}
					else
					{
						this.followTarget();
					}
				}
			}
		}
		
		override protected function attackTarget():void
		{
			this.faceToTarget();
			
			this.setAction("hit2");
			this.lastHit = "hit2";
		}
		
		override protected function beforeSkill1Start():Boolean
		{
			return this.hasTarget() && AUtils.GetDisBetweenTwoObj(this.curAttackTarget, this) < 100;
		}
		
		override protected function releSkill1():void
		{
			
			this.setInvincible(10);
			this.setAction("hit1");
			this.lastHit = "hit1";
		}
		
		override protected function exitFrameFunc(param1:Point):void
		{
		}
		
		override protected function myIntelligence():void
		{
			if (!this.isBeAttacking())
			{
				super.myIntelligence();
			}
			if (this.curAction != "swim" && !this.isAttacking() && !this.isBeAttacking())
			{
				if (Boolean(this.standInObj) && this.hasTarget())
				{
					if (this.curAttackTarget.y < this.y - 200)
					{
						this.isReadyToSwim = true;
						this.setAction("swim");
					}
				}
			}
			if (this.curAction == "swim")
			{
				if (!this.isReadyToSwim && Boolean(this.standInObj))
				{
					this.setAction("idle");
				}
			}
		}
		
		private function keepDisWithTarget():void
		{
			if (this.curAttackTarget)
			{
				if (this.x > this.curAttackTarget.x)
				{
					this.moveRight();
				}
				else if (this.x < this.curAttackTarget.x)
				{
					this.moveLeft();
				}
			}
		}
		
		private function doHi1(param1:uint):void
		{
			var _loc2_:FollowTargetBullet = new FollowTargetBullet("Monster301Bullet1");
			if (param1 == 0)
			{
				_loc2_.x = this.x - 60;
			}
			else
			{
				_loc2_.x = this.x + 60;
			}
			_loc2_.y = this.y - 30;
			_loc2_.setOwner(this);
			_loc2_.setDirect(param1);
			_loc2_.setAction("hit1");
			gc.gameScene.addChild(_loc2_);
			this.magicBulletArray.push(_loc2_);
		}
		
		private function doHi2(param1:uint):void
		{
			var _loc2_:EnemyMoveBullet = new EnemyMoveBullet("Monster301Bullet2");
			if (param1 == 0)
			{
				_loc2_.x = this.x - 20;
			}
			else
			{
				_loc2_.x = this.x + 20;
			}
			_loc2_.y = this.y - 20;
			var _loc3_:Point = McUtil.getTwoObjectAngle(_loc2_, this.curAttackTarget);
			_loc2_.setSpeed(_loc3_.x * 3, 0);
			_loc2_.setSpeedAdd(_loc3_.x, 0);
			_loc2_.setDistance(1000);
			_loc2_.setIsDestroyWhenLastFrame(false);
			_loc2_.setOwner(this);
			_loc2_.setDirect(param1);
			_loc2_.setAction("hit2");
			gc.gameScene.addChild(_loc2_);
			this.magicBulletArray.push(_loc2_);
		}
	}
}*/
